#!/bin/tcsh
set work=/hdd_ex/Data/Theta_cs/
set here=`pwd`
set target=`ls $here/$1`
echo $target
mkdir -p $here/$1/merge
foreach tar ($target)
	mv $here/$1/$tar/output.root $here/$1/merge/output$tar.root
end
cd $here/$1/merge
cp $work/Ana/merger.C .
ls > file.list
set nline=`cat file.list | wc -l`
root -l 'merger.C('$nline')'
mv merged.root $here/$1.root
cd $here
